<template>
  <div class="child">
    <h3>子组件1</h3>
    <h4>玩具：{{ toy }}</h4>
    <h4>书籍：{{ book }}-{{ count }}本</h4>
    <button @click="changeFatherHouse($parent)">修改父亲的房产</button>
  </div>
</template>

<script setup lang="ts" name="Child">
import { ref } from "vue";
let toy = ref("拉布布");
let book = ref("《三体》");
let count = ref(10);
function changeFatherHouse(father: any) {
  console.log(father);
  father.house -= 1;
}
//父亲要我的东西，我作为儿子可以暴露给父亲,使用宏函数暴露defineExpose()
//defineExpose表示把数据暴露出去给外面
defineExpose({ toy, book, count });
</script>

<style scoped>
.child {
  background-color: skyblue;
  padding: 10px;
  border-radius: 10px;
  box-shadow: 0 0 10px black;
}
</style>
